<?php
/**
 * Created by PhpStorm.
 * User: 技术员专用
 * Date: 2019/3/13
 * Time: 15:08
 */
class AysMysql{
    public $dbSource='';
    public function __construct()
    {
        $this->dbSource=new Swoole\MySQL;
//        $this->dbSource=new swoole_mysql();
        $this->dbConfig=[
            'host'=>'127.0.0.1',
            'port'=>'3306',
            'user'=>'live',
            'password'=>'127.0.0.1',
            'database'=>'127.0.0.1',
            'charset'=>'127.0.0.1',

        ];
    }
    public function add(){

    }
    public function update(){

    }
    public function execute($id,$username){
        $this->dbSource->connect($this->dbConfig,function ($db,$result){
            if ($result===false){
                var_dump($db->connect_error);
            }
            $sql="select * from `test` where `id`=1 ";
            $db->query($sql,function ($db,$result){
                if ($result===false){

                }elseif ($result==true){

                }else{
                    print_r($result);
                }
                $db->close();
            });

        });
        return true;
    }
}